<template>
  <div>
    <span v-for="ele in list" :key="ele">
      <input type="checkbox"  @click="flag(ele)">
      {{ele}}
    </span>
    <ul>
      <li v-for="ele in newArr" :key="ele" >
          {{ele}}
       
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data(){
    return{
      list:["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
      newArr:[]
    }
  },
 methods:{
  flag(ele){
    let i = this.newArr.findIndex(item => item === ele)
    if(i !== -1){
      this.newArr.splice(i,1)
    }else{
      this.newArr.push(ele)
    }
  }
 }
}
</script>

<style>

</style>